﻿<!---<cfdirectory action="list" name='mydir' type="dir" directory="\\SCFWEB1\CFMX\SCF Intranet">
<cfset mystruct = {} />
<cfloop query="mydir">
    <cfscript>
/*        import models.*;
        resource = entityNew("Resources");
        resource.setResource(mydir.Name);
        resource.setLocation(mydir.Directory);
        EntitySave(Resource, true);*/
    </cfscript>    
</cfloop>
--->


<cfscript>
Kronos = createObject('component', '#session.rootDir#.databasequeries.Kronos');
Users = createObject("component", "#session.rootDir#.objects.Users").init();

ad_users = {};
k_users = {};

Users = Users.getAllADUsers();
KronosInfo = Kronos.funcGetCurrentEmployeesByUserAccount(  );

for(i=1;i <= KronosInfo.RecordCount;i++){
    
    k_users['#KronosInfo.UserAccount[i]#'] = { 
        KronosFirstName = '#KronosInfo.firstname[i]#', 
        KronosNickName = '#KronosInfo.NickName[i]#'
    };
}

writeOutput('<table border=1><tr><td><strong>UserAccount</strong></td><td><strong>AD First Name</strong></td>
<td><strong>Kronos Nickname</strong></td><td><strong>AD Display Name</strong></td></tr>');

for(i=1;i <= Users.RecordCount;i++){

    try
    {
    	if( k_users['#Users.sAMAccountName[i]#'].KronosNickName NEQ "" AND trim(k_users['#Users.sAMAccountName[i]#'].KronosNickName) NEQ trim('#Users.givenName[i]#')){
	        ad_users['#Users.sAMAccountName[i]#'] = { 
	            ADFirstName = '#Users.givenName[i]#',
                ADDisplayName = '#Users.DisplayName[i]#',
                KronosFirstName = k_users['#Users.sAMAccountName[i]#'].KronosFirstName,
                KronosNickName = k_users['#Users.sAMAccountName[i]#'].KronosNickName
	        };
            writeOutput(
                '<tr>
                <td>#Users.sAMAccountName[i]# &nbsp;</td>
                <td>#Users.givenName[i]# &nbsp;</td>
                
                <td>#k_users['#Users.sAMAccountName[i]#'].KronosNickName# &nbsp;</td>
                <td>#Users.DisplayName[i]# &nbsp;</td>
                </tr>'
            );
	    
	    }/*else if( trim(k_users['#Users.sAMAccountName[i]#'].KronosFirstName) NEQ trim('#Users.givenName[i]#') ){    
	        ad_users['#Users.sAMAccountName[i]#'] = { 
	            ADFirstName = '#Users.givenName[i]#',
                ADDisplayName = '#Users.DisplayName[i]#',
                KronosFirstName = k_users['#Users.sAMAccountName[i]#'].KronosFirstName,
                KronosNickName = k_users['#Users.sAMAccountName[i]#'].KronosNickName
	        };
            writeOutput(
                '<tr>
                <td>#Users.sAMAccountName[i]# &nbsp;</td>
                <td>#Users.givenName[i]# &nbsp;</td>
                <td>#k_users['#Users.sAMAccountName[i]#'].KronosFirstName# &nbsp;</td>
                <td>#k_users['#Users.sAMAccountName[i]#'].KronosNickName# &nbsp;</td>
                <td>#Users.DisplayName[i]# &nbsp;</td>
                </tr>'
            );
	    }*/
    }
    catch(Any e)
    {
    }

    
}
writeOutput('</table>');

</cfscript>
